<?php 
/**
* @orm tableName forum_posts
* @orm listener afterInsert afterInsert
* @orm listener beforeDelete beforeDelete
*/
class ForumPost extends ForumPostBase {
	
	/**
	* @orm has parent ForumTopic inverse posts
	*/
	public $topic;
	
	public function afterInsert() {
		if( $this->user ) {
			$this->user->posts++;
			$entry = $this->user->getTodaysPointsEntry();
			$entry->points++;
			$entry->save();
			$this->user->save();
		}
	}
	
	public function beforeDelete() {
		if( $this->topic )
			$this->topic->beforeDeletePost( $this );
			
		$this->user->posts--;
		if( $this->user ) {
			$entry = $this->user->getTodaysPointsEntry();
			$entry->points--;
			$entry->save();
			$this->user->save();
		}
	}
	
		
	public function canAddImage( $image ) {
		return parent::canAddImage($image);
	}
	
	public function afterAddImage() {
		parent::afterAddImage();
	}
	
	public function afterRemoveImage() {
		parent::afterRemoveImage();
	}
	

}
?>